package com.matrix.java.chap_05;

import java.util.Scanner;

/*
    对元音和辅音进行计数
 */
public class Ex5_49 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("Enter a string: ");
        String str = input.nextLine();
        input.close();
        String vowels = "AEIOUaeiou";
        int vowelsCount = 0;
        int consonantsCount = 0;
        for (int i = 0; i < str.length(); i++) {
            if (vowels.contains(str.substring(i, i + 1))) {
                vowelsCount++;
            } else if (!str.substring(i, i + 1).equals(" ")) {
                consonantsCount++;
            }
        }
        System.out.println("The number of vowels is " + vowelsCount);
        System.out.println("The number of consonants is " + consonantsCount);
    }
}
